cmake_minimum_required(VERSION 3.8)
project(motdrv)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()


include_directories(
  include
  ${Boost_INCLUDE_DIRS}
  ${JSONCPP_INCLUDE_DIRS}
)
aux_source_directory(src SRC_LISTS)
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(ament_index_cpp REQUIRED)
# 查找MQTT和JSON库
find_package(PkgConfig REQUIRED)
#pkg_check_modules(MOSQUITTO REQUIRED libmosquitto)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
add_executable(motor_driver ${SRC_LISTS})
#add_executable(motor_driver src/motor_driver.cpp)
#target_include_directories(motor_driver PUBLIC
#  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
#  $<INSTALL_INTERFACE:include>)
#target_compile_features(motor_driver PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(motor_driver 
    rclcpp 
    std_msgs 
    nav_msgs 
    geometry_msgs 
    tf2 
    tf2_ros  
    tf2_geometry_msgs
    ament_index_cpp

    )
# 链接库
target_link_libraries(motor_driver
  ${JSONCPP_LIBRARIES}
)
install(TARGETS motor_driver
  motor_driver
  DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY launch config
  DESTINATION share/${PROJECT_NAME}
)


ament_package()
